<?php

namespace app\common\dao\info;

use app\common\model\info\Order as model;
use app\common\dao\BaseDao;

class OrderDao extends BaseDao
{
    /**
    * 设置模型
    * @return model
    */
    protected function getModel(): string
    {
        return model::class;
    }


    public function search($where)
    {
        $query = $this->getModel()::getDB();
        $query->when(isset($where['admin_id']) && $where['admin_id'] !== '', function ($query)use($where){
            $query->where('admin_id',$where['admin_id']);
        })->when(isset($where['status']) && $where['status'] !== '', function ($query)use($where){
            $query->where('status',$where['status']);
        })->when(isset($where['name']) && $where['name'] !== '', function ($query)use($where){
            $query->where('name','like',"%{$where['name']}%");
        })->when(isset($where['order_sn']) && $where['order_sn'] !== '', function ($query)use($where){
            $query->where('order_sn','like',"%{$where['order_sn']}%");
        })->when(isset($where['uid']) && $where['uid'] !== '', function ($query)use($where){
            $query->where('uid',$where['uid']);
        })->where('is_del',0);

        return $query;
    }
}